package geppetto.decoder.scores;

import java.util.HashMap;

import geppetto.decoder.TranslationHypothesis;
import geppetto.decoder.TranslationHypothesisScore;
import geppetto.decoder.TranslationOption;
import geppetto.phraseTable.phrase.Phrase;

abstract public class GraphPhraseProductScore implements TranslationHypothesisScore{

HashMap<TranslationHypothesis, Double> scoreForEachNode;
	
	@Override
	public void addOption(TranslationHypothesis baseHyp,
			TranslationHypothesis newHyp, TranslationOption option) {
		scoreForEachNode.put(newHyp, scoreForEachNode.get(baseHyp) * getPhraseScore(option.getPhrase()));
	}

	@Override
	public void init(TranslationHypothesis initialHypothesis) {
		scoreForEachNode = new HashMap<TranslationHypothesis, Double>();
		scoreForEachNode.put(initialHypothesis, 1d);
	}
	
	public double getScore(TranslationHypothesis key){
		return scoreForEachNode.get(key);
	}
	
	abstract public double getPhraseScore(Phrase p);
}
